<?php namespace Home\Model;
use Think\Model;

/**
 * Class 分类控制器
 * @package Home\Controller
 */
class CategoryModel extends Model
{

    public function GetCate(){

    	$cate="select * from category";
		$res=M('category')->query($cate);
		$temparr=[];
		foreach ($res as $top) {
			if ($top['fid']==0) {
				$temparr[]=$top;
			}
		}
		foreach ($temparr as $k => $v) {
			foreach ($res as $vs) {
				if ($vs['fid']==$v['id']) {
					$temparr[$k]['son'][] =$vs;
				}
			}
		}
		return $temparr;
    }


}